﻿// ===============================================================================
// XCI.NET 西安交通信息WinForm开发框架 2018 版权所有
// ===============================================================================
using System.ComponentModel;
using XCI.Core;

namespace XCI.Windows.Plugin.GridSetting.UI
{
    [ToolboxItem(false)]
    public partial class TreeTemplate : BaseGridTemplate
    {
        public TreeTemplate()
        {
            InitializeComponent();
        }

        private TreeSettingPlugin Plugin { get; set; }

        public void Initialize(TreeSettingPlugin uiplugin)
        {
            this.Plugin = uiplugin;
            Initialize();
        }

        protected override string GetId()
        {
            return Plugin.Id;
        }

        protected override string GetSetting()
        {
            return Plugin.GetSetting();
        }

        protected override BoolMessage ApplySetting(string data)
        {
            if (data != null)
            {
                Plugin.Tree.Columns.Clear();
                Plugin.Tree.FormatConditions.Clear();
                Plugin.Tree.Appearance.Reset();
                Plugin.SetSetting(data);

                Plugin.Tree.ViewInfo.PaintAppearance.HideSelectionRow.BackColor 
                    = Plugin.Tree.ViewInfo.PaintAppearance.FocusedRow.BackColor;
                return BoolMessage.True;
            }
            return new BoolMessage(false, "表格配置数据为空,无法应用配置");
        }
    }
}
